package com.rj.core.type;

import com.rj.core.check.DictList;

import java.util.function.Consumer;

/**
 * 字符类型
 *
 * @author YFX_RANLUBO
 * @date 2024/09/14 16:56
 **/
public class BeanType<T> {
    /**
     * 属性key
     */
    private String filedKey;
    /**
     * 属性名
     */
    private String filedName;
    /**
     * 是否允许为空
     */
    private boolean allowEmpty = true;
    /**
     * 最大长度
     */
    private Integer maxLength;
    /**
     * 正则匹配
     */
    private String regex;
    /**
     * 数据字典
     */
    private DictList<T> dict;
    /**
     * 自定义检查器
     */
    private Consumer<T> defCheck;

    public String getFiledKey() {
        return filedKey;
    }

    public String getFiledName() {
        return filedName;
    }

    public Boolean getAllowEmpty() {
        return allowEmpty;
    }

    /**
     * @param filedKey
     * @param filedName
     */
    public BeanType(String filedKey, String filedName) {
        this.filedKey = filedKey;
        this.filedName = filedName;
    }

    /**
     * @param filedKey
     * @param filedName
     * @param allowEmpty
     */
    public BeanType(String filedKey, String filedName, Boolean allowEmpty) {
        this.filedKey = filedKey;
        this.filedName = filedName;
        this.allowEmpty = allowEmpty;
    }

    /**
     * @param filedKey
     * @param filedName
     * @param allowEmpty
     */
    public BeanType(String filedKey, String filedName, Boolean allowEmpty, String regex) {
        this.filedKey = filedKey;
        this.filedName = filedName;
        this.allowEmpty = allowEmpty;
        this.regex = regex;
    }

    public BeanType(String filedKey, String filedName, boolean allowEmpty, Integer maxLength) {
        this.filedKey = filedKey;
        this.filedName = filedName;
        this.allowEmpty = allowEmpty;
        this.maxLength = maxLength;
    }

    public DictList<T> getDict() {
        return dict;
    }

    public BeanType<T> setDict(DictList<T> dict) {
        this.dict = dict;
        return this;
    }

    public Integer getMaxLength() {
        return maxLength;
    }

    public String getRegex() {
        return regex;
    }

    public Consumer<T> getDefCheck() {
        return defCheck;
    }

    public void setDefCheck(Consumer<T> defCheck) {
        this.defCheck = defCheck;
    }
}
